#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n); 
	int z[n+1][m+1];
	int max=0;
	memset(z,0,sizeof(z));
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			max=0;
			if(z[i-1][j]>max){
				max=z[i-1][j];
			}
			if(j>=a[i-1]){
				if(z[i-1][j-a[i-1]]+a[i-1]>max){
					max=z[i-1][j-a[i-1]]+a[i-1];
				}
			}
			z[i][j]=max;
		}
	}
	cout<<m-z[n][m];
}
